﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MySql.Data.MySqlClient;

/// <summary>
/// Summary description for Liability
/// </summary>
public class Liability
{
	private const string SP = "Liabilities_GetById";
	DatabaseManager db;
	MySqlDataReader reader;

	public string Id { get; set; }
	public int Year { get; set; }
	public int Equity { get; set; }
	public int LongTermLiabilities { get; set; }
	public int ShortTermLiabilities { get; set; }
	public int TotalLiabilities { get; set; }

	public Liability()
	{
    db = new DatabaseManager();
	}

  public void Load(string id, int year)
  {
    db.AddParameter("@id", id);
    db.AddParameter("@year", year);
    using (reader = db.ExecuteStoredProcedure(SP))
    {
      while (reader.Read())
      {
        Id = reader["id"].ToString();
        Year = Convert.ToInt32(reader["year"].ToString());
        Equity = Convert.ToInt32(reader["equity"].ToString());
        LongTermLiabilities = Convert.ToInt32(reader["long_term_liabilities"].ToString());
        ShortTermLiabilities = Convert.ToInt32(reader["short_term_liabilities"].ToString());
        TotalLiabilities = Convert.ToInt32(reader["total_liabilities"].ToString());
      }
    }
  }
}